package com.gxl.butt.DAO.impl;

import com.gxl.butt.DAO.ItopicStatusDAO;
import com.gxl.butt.domain.TopicStatus;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * Created by GUOXIAOLIN on 2018/7/13.
 */
@Repository
public class topicStatusDAOImpl extends HibernateBaseDao<TopicStatus> implements ItopicStatusDAO {

    @Override
    public boolean updateTopicStatus(TopicStatus topicStatus) {
        this.update((topicStatus));
        return true;
    }

    @Override
    public List<TopicStatus> getTopicStatusByTopicName(String topicName) {

        String hql = "from " + TopicStatus.class.getName() + " do where do.topicname='" + topicName+"'";
        List<TopicStatus> topicStatuses = this.getListByHql(hql);
        if (topicStatuses != null && topicStatuses.size() >0 ){
            return topicStatuses;
        }
        return null;

    }

    @Override
    public List<TopicStatus> getTopicStatusByTopicId(Long topicid) {

        String hql = "from " + TopicStatus.class.getName() + " do where do.topicid='" + topicid+"'";
        List<TopicStatus> topicStatuses = this.getListByHql(hql);
        if (topicStatuses != null && topicStatuses.size() >0 ){
            return topicStatuses;
        }
        return null;

    }

    @Override
    public Long saveTopicStatus(TopicStatus topicStatus) {
        return (Long) this.save(topicStatus);
    }
}
